home *** CD-ROM | disk | FTP | other *** search
/ Champak 54 / Vol 54.iso / games / virtual_.swf / scripts / DefineSprite_709 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-09-27  |  3.3 KB  |  139 lines

  1. foodLevel = 50;
  2. foodRythme = 0.03;
  3. exerciceLevel = 75;
  4. exerciceRythme = 0.02;
  5. careLevel = 60;
  6. careRythme = 0.04;
  7. Wellness = (careLevel + foodLevel + ExerciceLevel) / 3;
  8. TheEnd = flase;
  9. animStack = new Array();
  10. scoreStats = new Array();
  11. animCount = 0;
  12. animPlay = false;
  13. animCount = animStack.push("Idle");
  14. AnimHappyAvailable = true;
  15. AnimDepress01Available = true;
  16. AnimDepress02Available = true;
  17. AnimHungryAvailable = true;
  18. countTimeLiter = false;
  19. initTime = getTimer();
  20. _root.onEnterFrame = function()
  21. {
  22.    foodLevel -= foodRythme;
  23.    exerciceLevel -= exerciceRythme;
  24.    careLevel -= careRythme;
  25.    Wellness = (careLevel + foodLevel + ExerciceLevel) / 3;
  26.    if(animPlay == false and animStack.length > 0)
  27.    {
  28.       tempAnimName = animStack.pop();
  29.       trace("Joue: " + tempAnimName);
  30.       Cat.gotoAndPlay(tempAnimName);
  31.       animPlay = true;
  32.    }
  33.    if(Wellness > 80 and AnimHappyAvailable == true)
  34.    {
  35.       if(random(100) == 10)
  36.       {
  37.          animCount = animStack.push("Happy");
  38.          AnimHappyAvailable = false;
  39.       }
  40.    }
  41.    if(Wellness > 30 and Wellness < 50 and AnimDepress01Available == true)
  42.    {
  43.       if(random(100) == 10)
  44.       {
  45.          animCount = animStack.push("Depress01");
  46.          AnimDepress01Available = false;
  47.       }
  48.    }
  49.    if(Wellness < 30 and Wellness > 10 and AnimDepress02Available == true)
  50.    {
  51.       if(random(100) == 10)
  52.       {
  53.          animCount = animStack.push("Depress02");
  54.          AnimDepress02Available = false;
  55.       }
  56.    }
  57.    if(Wellness < 1)
  58.    {
  59.       TheEnd = true;
  60.       animCount = animStack.push("WalkAway");
  61.    }
  62.    if(foodLevel < 30 and AnimHungryAvailable == true)
  63.    {
  64.       if(random(100) == 10)
  65.       {
  66.          animCount = animStack.push("Hungry");
  67.          AnimHungryAvailable = false;
  68.       }
  69.    }
  70.    if(random(2000) == 50)
  71.    {
  72.       animCount = animStack.push("Toilette");
  73.       countTimeLiter = true;
  74.    }
  75.    if(countTimeLiter == true)
  76.    {
  77.       CountMaskTime++;
  78.       if(CountMaskTime == 500)
  79.       {
  80.          animCount = animStack.push("Mask");
  81.          CountMask = 0;
  82.       }
  83.    }
  84.    actualTime = getTimer();
  85.    if(actualTime - initTime >= 30000)
  86.    {
  87.       trace("UNE MINUTE!");
  88.       TimeLine.nextFrame();
  89.       initTime = getTimer();
  90.       scoreCount = scoreStats.push(Wellness);
  91.    }
  92.    if(foodLevel - exerciceLevel > 20 and foodLevel - exerciceLevel < 40)
  93.    {
  94.       Cat.Bid.gotoAndStop("Normal");
  95.       Cat.Cou.gotoAndStop("Normal");
  96.    }
  97.    if(foodLevel < 20)
  98.    {
  99.       Cat.Bid.gotoAndStop("Small");
  100.       Cat.Cou.gotoAndStop("Small");
  101.    }
  102.    if(foodLevel - exerciceLevel > 40)
  103.    {
  104.       Cat.Bid.gotoAndStop("Medium");
  105.       Cat.Cou.gotoAndStop("Madium");
  106.    }
  107.    if(foodLevel > 100)
  108.    {
  109.       exerciceLevel -= 10;
  110.       foodLevel = 100;
  111.    }
  112.    if(careLevel > 100)
  113.    {
  114.       exerciceLevel -= 10;
  115.       careLevel = 100;
  116.    }
  117.    if(exerciceLevel > 100)
  118.    {
  119.       foodLevel -= 10;
  120.       exerciceLevel = 100;
  121.    }
  122. };
  123. calculateScore = function()
  124. {
  125.    if(TheEnd != true)
  126.    {
  127.       i = 0;
  128.       while(i < 10)
  129.       {
  130.          Total += scoreStats[i];
  131.          i++;
  132.       }
  133.       Moy = Total / 10;
  134.       trace("GameOVER.  Your score is : " + Moy);
  135.       _root.Score = String(Math.round(Moy * 100) / 100) + " %";
  136.       _root.gotoAndStop("GameOverWin");
  137.    }
  138. };
  139.